﻿using Aspose.Words;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;

namespace AsposeWordTest
{
    public class AsposeWordHelper
    {
        public static string BasePath = "D:/test/";
        public void Build()
        {
            Document doc = new Document();

            DocumentBuilder builder = new DocumentBuilder(doc);
            builder.InsertField("test");
            builder.InsertParagraph();
            builder.InsertField("test");

            byte[] image = GetImage();
            builder.InsertImage(image);


            string path = $"{BasePath}test.docx";
            doc.Save(path, SaveFormat.Docx);
        }

        private byte[] GetImage()
        {
            string path = $"{BasePath}test.jpg";
            return File.ReadAllBytes(path);
        }
    }
}
